<script>
  var minimumAbsDifference = function (arr) {
    arr.sort((a, b) => a - b);
    let ans = [];
    let min = Infinity;
    for (let i = 1; i < arr.length; i++) {
      const prev = arr[i - 1];
      const now = arr[i];
      const c = now - prev;
      if (c < min) {
        min = c;
        ans = [[prev,now]];
      }else if(c===min){
        ans.push([prev,now]);
      }
    }
    return ans;
  };
  console.log(minimumAbsDifference([4, 2, 1, 3]));
</script>